package mp

import (
	"net/http"

	"github.com/zeromicro/go-zero/rest/httpx"
	"ruikc.com/server/api/internal/logic/mp"
	"ruikc.com/server/api/internal/svc"
	tojson "ruikc.com/tojson"
)

func CategoryListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		l := mp.NewCategoryListLogic(r.Context(), svcCtx)
		resp, err := l.CategoryList()
		if err != nil {
			httpx.OkJsonCtx(r.Context(), w, tojson.Error(err))
		} else {
			httpx.OkJsonCtx(r.Context(), w, tojson.Success(resp))
		}
	}
}
